import request, { headers } from '@/utils/request'
import qs from 'qs'

export default {
  git: {
    cloneRepository(group,url){return request.get(`/git/cloneRepository?group=${group}&url=${url}`)},
    repositories(group){return request.get(`/git/repositories?group=${group}`)},
    branches(group,repository){ return request.get(`/git/branches?group=${group}&repository=${repository}`)},
    filterPageBranches(filterParam,pageParam){return request.get('/git/filterBranchesPage',{params: {...filterParam,...pageParam}})},
    currentBranch(group,repository){return request.get(`/git/currentBranch?group=${group}&repository=${repository}`)},
    switchBranch(group,repository,branchName){return request.get(`/git/switchBranch?group=${group}&repository=${repository}&branchName=${branchName}`)},
    pull(group,repository){return request.get(`/git/pull?group=${group}&repository=${repository}`) },
    commits(group,repository){return request.get(`/git/commits?group=${group}&repository=${repository}`)},
    diffChanges(choseCommits){return request.post('/git/diffChanges',choseCommits,headers.json)},
    diffTree(choseCommits){return request.post('/git/diffTree',choseCommits,headers.json)},

    downloadSource(tarFileParam){return request.post('/git/source/download',tarFileParam,headers.json)}
  },
  project: {
    modules(projectLocation){return request.get('/project/maven/modules',{params: {...projectLocation}})},
    guessCompileModules(choseCommits){return request.post('/project/maven/guessCompileModules',choseCommits,headers.json)},
    executeGoals(mavenGoalsParam){return request.post('/project/maven/execute/goals',mavenGoalsParam,headers.json)},
    resolveDependencies(moduleResolveDepParam){return request.post('/project/maven/resolve/dependencies',moduleResolveDepParam,headers.json)},
    compileLittleFiles(javacCompileFiles){return request.post('/project/maven/compileLittleFiles',javacCompileFiles,headers.json)},
    compileLittleFilesByCommits(choseCommits){return request.post('/project/maven/compile/commits',choseCommits,headers.json)},
    compileMultiFilesByMaven(mavenCompileParam){return request.post('/project/maven/compile/maven',mavenCompileParam,headers.json)},

    lastResolveTime(moduleResolveDepParam){return request.post('/project/module/classpath/lastResolveTime',moduleResolveDepParam,headers.json)},
    binFileParse(tarFileParam){return request.post('/project/maven/bin/metaParse',tarFileParam,headers.json)},
    downloadBinFiles(tarFileParam){return request.post('/project/maven/bin/download',tarFileParam,headers.json)}
  },
  patch: {
    historyPatch(group, repository) { return request.get('/patch/list', { params: { group, repository }}) },
    deleteHistoryPatch(filepath) { return request.post('/patch/deletePatch', qs.stringify({ filepath }, headers.urlencoded)) },
    cleanNotEffectHistoryPatch() { return request.post('/patch/cleanNotEffectPatch') }
  }

}
